<template>
  <el-dialog
    v-dialogDrag
    title="用户分配"
    :visible.sync="this.$parent.userdialogVisible"
    width="60%"
    length="100%"
    :before-close="this.$parent.handleClose"
  >
    <el-form :inline="true">
      <el-form-item label="用户名称：">
        <el-input v-model='queryName' placeholder="请输入用户名称" />
      </el-form-item>
      <el-button
        style="margin-left: 5px"
        type="primary"
        @click="queryUserByName"
      >查询</el-button>
    </el-form>
    <el-table
      ref="userTable"
      v-loading="this.$parent.listLoading"
      :data="this.$parent.userData"
      selectable
      highlight-current-row
      height="350"
      style="width: 100%"
      @select="this.$parent.handleSelectionChange"
    >
      <el-table-column type="selection" />
      <el-table-column label="用户工号" align="center">
        <template slot-scope="scope">
          {{ scope.row.code }}
        </template>
      </el-table-column>
      <el-table-column label="用户名" align="center">
        <template slot-scope="scope">
          {{ scope.row.name }}
        </template>
      </el-table-column>
      <el-table-column label="公司" align="center" prop="company.name" />
      <el-table-column label="部门" align="center" prop="departmentVO.name" />
    </el-table>
    <!-- 分页条-->
    <el-pagination
      :v-model="this.$parent.userPage"
      :current-page.sync="this.$parent.userPage.pageNum"
      :page-size="this.$parent.userPage.pageSize"
      :page-sizes="[15]"
      layout="total,sizes,prev, pager, next, jumper"
      :total="this.$parent.userPage.total"
      @size-change="this.$parent.handleUserSizeChange"
      @current-change="this.$parent.handleUserDataChange"
    />
    <span slot="footer">
        <el-button
          style="margin-left: 30px"
          @click="this.$parent.cancelUser"
        >取 消</el-button>
        <el-button v-btpermission='"角色管理-按钮（POST）-/assignUser"'   type="primary" @click="this.$parent.assignUser">确 定</el-button>
      </span>
  </el-dialog>
</template>

<script>
export default {
  name: 'user_dialog',
  props:{
    username:{
      type:String,
      require:true
    }
  },
  mounted() {
  },
  data(){
    return{
      queryName:this.username
    }
  },
  methods:{
    queryUserByName(){
      this.$parent.userQuery.name = this.queryName
      this.$emit("queryUserByName")
    }
  }
}
</script>

<style scoped>

</style>
